package cache_service

import (
	"gin_blog/pkg/e"
	"strconv"
	"strings"
)

type Article struct {
	ID int
	TagID int
	State int

	PageNum int
	PageSize int
}

func (a *Article)GetArticleKey() string {
	return e.CACHE_ARTICLE + "_" + strconv.Itoa(a.ID)
}
func (a *Article)GetArticlesKey() string {
	keys :=[]string{
		e.CACHE_ARTICLE,
		"LIST",
	}
	if a.ID>0{
		keys=append(keys,strconv.Itoa(a.ID))
	}
	if a.TagID>0{
		keys=append(keys,strconv.Itoa(a.TagID))
	}
	if a.State>=0{
		keys=append(keys,strconv.Itoa(a.State))
	}
	if a.PageSize>0{
		keys=append(keys,strconv.Itoa(a.PageSize))
	}
	if a.PageNum>0{
		keys=append(keys,strconv.Itoa(a.PageNum))
	}
	return strings.Join(keys,"_")
}

